#include<bits/stdc++.h>
using namespace std;

int n;

int bow[15];
int col[15];
int vis[15][15];

int num = 0;
vector<int> posSolution[10000005];

inline bool check(int x, int y) {

    // left top
    for(int i = x - 1, j = y - 1; i > 0 && j > 0; i--, j--) {
        if(vis[i][j]) {
            return false;
        }
    }

    // right top
    for(int i = x - 1, j = y + 1; i > 0 && j <= n; i--, j++) {
        if(vis[i][j]) {
            return false;
        }
    }

    return true;
}

inline void dfs(int k) {
    if(k == n + 1) {
    	num++;
        for(int i = 1; i <= n; i++)
            posSolution[num].push_back(bow[i]);
        return ;
    }

    for(int i = 1; i <= n; i++) {
        if(col[i])	continue;
        if(!check(k, i))	continue;

        bow[k] = i;

        col[i] = 1;
        vis[k][i] = 1;
        dfs(k + 1);
        col[i] = 0;
        vis[k][i] = 0;
    }
}

signed main() {
    cin >> n;
    dfs(1);

    int ans = 0;
    for(int i = 1; i <= num; i++) {
        for(int j = i + 1; j <= num; j++) {
            bool flag = 0;
            for(int k = 0; k < n; k++) {
                if(posSolution[i][k] == posSolution[j][k]) {
                    flag = 1;
                    break;
                }
            }
            if(!flag)
                ans++;
        }
    }
    cout << ans * 2;
    return 0;
}


